package com.bbcare.followup.plat.controller;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.bbcare.comm.*;
import com.bbcare.department.plat.service.impl.DepartmentBasicService;
import com.bbcare.followup.plat.entity.FuAssessMentPosition;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bbcare.department.plat.service.IBsStaticParamService;
import com.bbcare.followup.plat.entity.EltDstRecored;
import com.bbcare.followup.plat.entity.Patient;
import com.bbcare.followup.plat.entity.PtEvaluationResult;
import com.bbcare.followup.plat.service.IFollowEvaluationScoreService;
import com.bbcare.followup.plat.service.IFollowEvaluationService;
import com.bbcare.followup.plat.service.IMabcEvaluationService;
import com.bbcare.followup.plat.service.IPatientService;

import static com.bbcare.comm.Constants.EVALUATION_GUIDE;


/**
 * @desc 随访评测接入类
 * @author tao
 *
 */
@Controller
@RequestMapping("/service/patient")
public class FollowEvaluationController {

	private final Log logger = LogFactory.getLog(FollowEvaluationController.class);

	@Autowired
	private IFollowEvaluationService followEvaluationService;

    @Autowired
    private IFollowEvaluationScoreService followEvaluationScoreService;

	@Autowired
	private IPatientService patientService;

	@Autowired
	private IMabcEvaluationService mabcEvaluationService;

	@Autowired
   	private IBsStaticParamService bsStaticParamService;

	@Autowired
	private DepartmentBasicService departmentBasicService;

	@ResponseBody
    @RequestMapping("/evaluation/getAllPostion")
    public ResultModel<Object> getAllPostion(@RequestBody String arg,
            HttpServletRequest request) throws Exception {
    	logger.info("in getAllPostion----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
        String examinationPaperName = requestParam.getString("examinationPaperName");
        if(StringUtils.isEmpty(examinationPaperName)){
        	logger.info("out getAllPostion----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，examinationPaperName不能为空");
        }

        /*Map<String, Object> paramMap = new HashMap<String, Object>();*/
        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	logger.info("out getAllPostion----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者id不能为空");
        }

        Map<String,Object> ptMap = new HashMap<String,Object>();
		ptMap.put("userId",userId);
		ptMap.put("tenantId",tenantId);
		Patient pt = patientService.getPatient(ptMap);
		if(pt == null ){
            throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_PATIENT_NOT_EXIST, "患者信息不存在");
		}

        Map<String,Object> paramsMap = new HashMap<String,Object>();
		if(Constants.FOLLOW_EVALUATION_NEUR.equals(examinationPaperName)){
			paramsMap = followEvaluationService.getNeuropsychologyPostion();
		}else if(Constants.FOLLOW_EVALUATION_BAILEY.equals(examinationPaperName)) {
			paramsMap = followEvaluationService.getBaileyScreeningPostion();
		}else if(Constants.FOLLOW_EVALUATION_GESELL.equals(examinationPaperName)) {
			paramsMap = followEvaluationService.getGesellPostion();
		}else if(Constants.FOLLOW_EVALUATION_TEMP.equals(examinationPaperName)) {
			String createTime = requestParam.getString("createTime");
			paramsMap = followEvaluationService.getTemperamentPostion(pt,createTime);
		}else if(Constants.FOLLOW_EVALUATION_WECHSLER.equals(examinationPaperName)) {
//			String birthday= request.getParameter("birthday");
			paramsMap = followEvaluationService.getWechslerPostion(DateUtil.getDate_8(pt.getBirthday()));
		}else if(Constants.FOLLOW_EVALUATION_HIGH_PREGNANT.equals(examinationPaperName)) {
//			String birthday= request.getParameter("birthday");
			paramsMap = followEvaluationService.getHighPregnantPostion(paramsMap);
		}else if(Constants.FOLLOW_EVALUATION_PREGNANT_SDS.equals(examinationPaperName)) {
//			String birthday= request.getParameter("birthday");
			List<Map<String,Object>> list = followEvaluationService.getPregnantSDSPostion(paramsMap);
			return new ResultModel<Object>(list);
		}else if(Constants.FOLLOW_EVALUATION_PREGNANT_SAS.equals(examinationPaperName)) {
//			String birthday= request.getParameter("birthday");
			List<Map<String,Object>> list = followEvaluationService.getPregnantSASPostion(paramsMap);
			return new ResultModel<Object>(list);
		}else if(Constants.FOLLOW_EVALUATION_PREGNANT_EPDS.equals(examinationPaperName)) {
//			String birthday= request.getParameter("birthday");
			List<Map<String,Object>> list = followEvaluationService.getPregnantEPDSPostion(paramsMap);
			return new ResultModel<Object>(list);
		}else if(Constants.FOLLOW_EVALUATION_PREGNANT_AIMS.equals(examinationPaperName)){
			paramsMap = followEvaluationService.getAIMSPostion(paramsMap);
		}else if(Constants.FOLLOW_EVALUATION_PREGNANT_SDQ.equals(examinationPaperName)){
			paramsMap.put("EVALUATION_KEY",Constants.FOLLOW_EVALUATION_PREGNANT_SDQ);
			List<JSONObject> list  = followEvaluationService.getPregnantCommonPostion(paramsMap);
			return new ResultModel<Object>(list);
		}else if(Constants.FOLLOW_EVALUATION_PREGNANT_PEABODY.equals(examinationPaperName)){
			paramsMap = followEvaluationService.getPregnantPeabodyPostion(paramsMap);
		}else if(Constants.FOLLOW_EVALUATION_PREGNANT_BSID.equals(examinationPaperName)){
			paramsMap = followEvaluationService.getPregnantBSIDPostion(paramsMap);
		}else if(Constants.FOLLOW_EVALUATION_PREGNANT_BSID2.equals(examinationPaperName)){
			paramsMap = followEvaluationService.getPregnantBSID2Postion(paramsMap);
		}else if(Constants.FOLLOW_EVALUATION_PREGNANT_LES.equals(examinationPaperName)||Constants.FOLLOW_EVALUATION_PREGNANT_OSI.equals(examinationPaperName)
				||Constants.FOLLOW_EVALUATION_PREGNANT_GLE.equals(examinationPaperName)||Constants.FOLLOW_EVALUATION_PREGNANT_FHRIS.equals(examinationPaperName)){
			paramsMap.put("examinationPaperName", examinationPaperName);
			paramsMap.put("patient" , pt);
			paramsMap = followEvaluationService.getPregnantLESPostion(paramsMap);
		}else if(Constants.FOLLOW_EVALUATION_DST.equals(examinationPaperName)) {
			paramsMap = followEvaluationService.getDSTPostion(paramsMap);
		}else if(Constants.FOLLOW_EVALUATION_NBNA.equals(examinationPaperName) && tenantId.equals("xmetyyta001")){//厦门nbna特殊指导
			String ageMonth = requestParam.getString("ageMonth");
			paramsMap.put("key" , "NBNA_AGE_" + ageMonth);
			paramsMap.put("field" , "NBNA_GUIDE");
			paramsMap.put("type" , "NBNA_GUIDE");
			paramsMap = followEvaluationScoreService.getNbnaGuide(paramsMap);
		}
		return new ResultModel<Object>(paramsMap);
    }

	@ResponseBody
    @RequestMapping("/evaluation/getScore")
    public ResultModel<Map<String, Object>> getScore(@RequestBody String arg, HttpServletRequest request) throws Exception {
    	logger.info("in getAllPostion----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
        String examinationPaperName = requestParam.getString("examinationPaperName");
        if(StringUtils.isEmpty(examinationPaperName)){
        	logger.info("out getScore----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，examinationPaperName不能为空");
        }

        String queueId = requestParam.getString("queueId");

        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        String authorId = (String) sessionMap.get("authorId");// 医生ID
        String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	logger.info("out getAllPostion----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者id不能为空");
        }

        String postionIds = requestParam.getString("postionIds");
        String taskId = requestParam.getString("taskId");
        if(StringUtils.isEmpty(postionIds)){
        	logger.info("out getAllPostion----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，postionIds不能为空");
        }

        String business = requestParam.getString("business");
        if(StringUtils.isBlank(business)) {
        	business = "评估医生";
        }

        String sourceType = requestParam.getString("sourceType");

        Map<String,Object> ptMap = new HashMap<String,Object>();
		ptMap.put("userId",userId);
		ptMap.put("tenantId",tenantId);
		Patient pt = patientService.getPatient(ptMap);
		if(pt == null ){
            throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_PATIENT_NOT_EXIST, "患者信息不存在");
		}

		Map<String,Object> paramsMap = new HashMap<String,Object>();
//		String postion="";
		if(pt.getBirthday()!=null||Constants.FOLLOW_EVALUATION_PREGNANT_DGLE.equals(examinationPaperName)) {
			Map<String, Object> scoreMap = new HashMap<String,Object>();
			Date birthday = null;
			if(!Constants.FOLLOW_EVALUATION_PREGNANT_DGLE.equals(examinationPaperName)) {
				birthday = DateUtil.getDate_8(pt.getBirthday());
			}
			if(Constants.FOLLOW_EVALUATION_NEUR.equals(examinationPaperName)) {
				ArrayList<Object> ids = new ArrayList<Object>();
				JSONArray postions = new JSONArray(postionIds);
				for (int i=0; i<postions.length(); i++) {
					ids.add(postions.getString(i));
				}
//				postion = ids.toString();
				scoreMap= followEvaluationScoreService.getNeuropsychologyScore(ids,birthday);
				if("true".equals(PropertiesUtils.getProperty("neuropsychologyGuide"))){
					paramsMap.put("guide",followEvaluationScoreService.getNeuropsychologyGuide(scoreMap,birthday));
				}


				paramsMap.put("bigMovement", scoreMap.get("大 运 动").toString());
				paramsMap.put("fineAction", scoreMap.get("精细动作").toString());
				paramsMap.put("adaptability", scoreMap.get("适应能力").toString());
				paramsMap.put("language", scoreMap.get("语    言").toString());
				paramsMap.put("socialBehavior", scoreMap.get("社交行为").toString());
				paramsMap.put("score", scoreMap.get("总分").toString());
			} else if(Constants.FOLLOW_EVALUATION_BAILEY.equals(examinationPaperName)){
				ArrayList<Object> ids = new ArrayList<Object>();
				JSONArray postions = new JSONArray(postionIds);
				for (int i = 0; i < postions.length(); i++) {
					ids.add(postions.getString(i));
				}
//				postion = ids.toString();
				//纠正胎龄不足280天，月龄 = 当前日期 - 预产期， 预产期 = 出生日期 +（280 - 纠正胎龄）;
				if(pt.getPregnancyDay()<259) {
					int day = 280 - pt.getPregnancyDay();
					birthday = DateUtil.addDay(birthday, day);
				}
				scoreMap= followEvaluationScoreService.getBaileyScreeningScore(ids, birthday);
				paramsMap = scoreMap;
			} else if(Constants.FOLLOW_EVALUATION_GESELL.equals(examinationPaperName)) {
				JSONObject jasonObject = JSON.parseObject(postionIds);
				Map<String,Object>map = jasonObject.getJSONObject("map");
//				postion = map.toString();
				paramsMap= followEvaluationScoreService.getGesellScore(map, birthday);
			} else if(Constants.FOLLOW_EVALUATION_TEMP.equals(examinationPaperName)) {
				JSONObject jasonObject = JSON.parseObject(postionIds);
				Map<String,Object>map = jasonObject.getJSONObject("map");
//				postion = map.toString();
				//纠正胎龄不足280天，月龄 = 当前日期 - 预产期， 预产期 = 出生日期 +（280 - 纠正胎龄）;
				int days = DateUtil.daysBetween(birthday, new Date());
				int month = days % 30 > 15 ? days / 30 + 1 : days / 30;
				if(pt.getPregnancyDay()<260 && month<25 && pt.getPregnancyDay()>0) {
					int day = 280 - pt.getPregnancyDay();
					birthday = DateUtil.addDay(birthday, day);
				}
				paramsMap= followEvaluationScoreService.getTemperamentScore(birthday, map);
			} else if(Constants.FOLLOW_EVALUATION_SMALlWECHSLER.equals(examinationPaperName)) {
				JSONObject jasonObject = JSON.parseObject(postionIds);
				Map<String,Object>map = jasonObject.getJSONObject("map");
				int day = DateUtil.daysBetween(birthday, new Date());
				map.put("day", day);
				paramsMap = followEvaluationScoreService.getSmallWechslerScore(map);
//				if((Boolean)paramsMap.get("success")==false) return paramsMap;
			} else if(Constants.FOLLOW_EVALUATION_BIGWECHSLER.equals(examinationPaperName)) {
				JSONObject jasonObject = JSON.parseObject(postionIds);
				Map<String,Object>map = jasonObject.getJSONObject("map");
				int day = DateUtil.daysBetween(birthday, new Date());
				map.put("day", day);
				paramsMap = followEvaluationScoreService.getBigWechslerScore(map);
//				if((Boolean)paramsMap.get("success")==false) return paramsMap;
			} else if(examinationPaperName.equals("nbna")) {
				String postionScores = requestParam.getString("postionScores");
				JSONObject jasonObject = JSON.parseObject(postionScores);
				paramsMap = jasonObject.getJSONObject("map");
			}else if(Constants.FOLLOW_EVALUATION_HIGH_PREGNANT.equals(examinationPaperName)||
					Constants.FOLLOW_EVALUATION_PREGNANT_SDS.equals(examinationPaperName)||
					Constants.FOLLOW_EVALUATION_PREGNANT_SAS.equals(examinationPaperName)||
					Constants.FOLLOW_EVALUATION_PREGNANT_EPDS.equals(examinationPaperName)||
					Constants.FOLLOW_EVALUATION_PREGNANT_GMS.equals(examinationPaperName)||
					Constants.FOLLOW_EVALUATION_PREGNANT_DGLE.equals(examinationPaperName)){
				String postionScores = requestParam.getString("postionScores");
				JSONObject jasonObject = JSON.parseObject(postionScores);
				paramsMap = jasonObject;
			}else if(Constants.FOLLOW_EVALUATION_PREGNANT_AIMS.equals(examinationPaperName)){
				Map<String,Object> map = new HashMap<String,Object>();
				map.put("patient",pt);
				map.putAll(requestParam);
				paramsMap= followEvaluationScoreService.getAimsScore(map);
			}else if(Constants.FOLLOW_EVALUATION_PREGNANT_SDQ.equals(examinationPaperName)){
				Map<String,Object> map = new HashMap<String,Object>();
				map.put("patient",pt);
				map.putAll(requestParam);
				paramsMap= followEvaluationScoreService.getSDQScore(map);
			}else if(Constants.FOLLOW_EVALUATION_PREGNANT_PEABODY.equals(examinationPaperName)){
				Map<String,Object> map = new HashMap<String,Object>();
				map.put("patient",pt);
				map.putAll(requestParam);
				paramsMap= followEvaluationScoreService.getPEABODYScore(map);
			}else if(Constants.FOLLOW_EVALUATION_PREGNANT_BSID2.equals(examinationPaperName)){
				Map<String,Object> map = new HashMap<String,Object>();
				map.put("patient",pt);
				map.putAll(requestParam);
				paramsMap= followEvaluationScoreService.getBSID2Score(map,Constants.FOLLOW_EVALUATION_PREGNANT_BSID2);
			}else if(Constants.FOLLOW_EVALUATION_PREGNANT_BSID.equals(examinationPaperName)){
				Map<String,Object> map = new HashMap<String,Object>();
				map.put("patient",pt);
				map.putAll(requestParam);
				paramsMap= followEvaluationScoreService.getBSID2Score(map,Constants.FOLLOW_EVALUATION_PREGNANT_BSID);
			}else if(Constants.FOLLOW_EVALUATION_PREGNANT_BSID.equals(examinationPaperName)){
				Map<String,Object> map = new HashMap<String,Object>();
				map.put("patient",pt);
				map.putAll(requestParam);
				paramsMap= followEvaluationScoreService.getLESScore(map);
			}else if(Constants.FOLLOW_EVALUATION_PREGNANT_FHRIS.equals(examinationPaperName)){
				Map<String,Object> map = new HashMap<String,Object>();
				map.put("patient",pt);
				map.putAll(requestParam);
				paramsMap= followEvaluationScoreService.getFHRISScore(map);
			}else if(Constants.FOLLOW_EVALUATION_DST.equals(examinationPaperName)){
				Map<String,Object> map = new HashMap<String,Object>();
				map.put("patient",pt);
				map.putAll(requestParam);
				paramsMap= followEvaluationScoreService.getDSTScore(map);
			}
	    	if(authorId !=null) {
	    		if(Constants.FOLLOW_EVALUATION_DST.equals(examinationPaperName)) {
	    			EltDstRecored dst = new EltDstRecored();
	    			dst.setId(SeqUtil.getSeqNo());
	    			dst.setUserName(pt.getUserName());
	    			dst.setUserId(userId);
	    			dst.setGender(pt.getGender());
	    			dst.setBirthday(pt.getBirthday());
	    			dst.setPregnancyDay(pt.getPregnancyDay());
	    			dst.setPhoneNo(pt.getPhoneNo());
	    			dst.setRemark("");
	    			dst.setSourceId("");
	    			dst.setSportsScore(""+paramsMap.get("sportsScore"));
	    			dst.setSociologyScore(""+paramsMap.get("sociologyScore"));
	    			dst.setIntelligenceScore(""+paramsMap.get("intelligenceScore"));
	    			dst.setDqScore((String)paramsMap.get("DQ"));
	    			dst.setMiScore((String)paramsMap.get("MI"));
	    			if(!StringUtils.isBlank(requestParam.getString("testTime"))) {
						SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
						try {
							format.parse(requestParam.getString("testTime"));
							dst.setTestTime(requestParam.getString("testTime"));
						} catch (Exception e) {
							 throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_PATIENT_NOT_EXIST, "日期格式不正确");
						}
					}else {
						dst.setTestTime(DateUtil.getDate_8(new Date()));
					}
	    			dst.setCreateTime(DateUtil.getSysDateA());
	    			if(StringUtils.isEmpty(sourceType)){
	    				dst.setSourceType(Constants.SOURCE_TYPE_FOLLOW);
	    			}else{
	    				dst.setSourceType(sourceType);
	    			}
	    			dst.setTenantId(tenantId);
	    			dst.setOpUsertype(Constants.OPCODE_TYPE_DOCTOR);
	    			dst.setQueueId(queueId);
	    			dst.setSubmitId("");
	    			dst.setTaskId(taskId);
	    			dst.setResult(postionIds);
	    			followEvaluationService.saveEltDstRecoreResults(dst);
	    		}else {
					//考试结果保存入库
		    		PtEvaluationResult answer = new PtEvaluationResult();
					answer.setType(examinationPaperName);
					answer.setId(SeqUtil.getSeqNo());
					answer.setDoctorid(authorId);
					answer.setCreateTime(DateUtil.getSysDateA());
					answer.setScore(JSON.toJSONString(paramsMap));
					if(Constants.FOLLOW_EVALUATION_PREGNANT_DGLE.equals(examinationPaperName) && paramsMap!=null) {
						answer.setResult(JSON.toJSONString(paramsMap));
					}else {
						answer.setResult(postionIds);
					}

					if(!StringUtils.isEmpty(requestParam.getString("sourceType"))){
						answer.setSourcetype(requestParam.getString("sourceType")); //暂时只有随访系统评估
					}else{
						answer.setSourcetype(Constants.SOURCE_TYPE_FOLLOW); //暂时只有随访系统评估
					}

					answer.setSourceid(authorId);
					answer.setTenantId(tenantId);
					answer.setUserId(userId);
					answer.setTaskId(taskId);
					if(!StringUtils.isBlank(requestParam.getString("testTime"))) {
						SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
						try {
							format.parse(requestParam.getString("testTime"));
							answer.setTestTime(requestParam.getString("testTime"));
						} catch (Exception e) {
							 throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_PATIENT_NOT_EXIST, "日期格式不正确");
						}
					}else {
						answer.setTestTime(DateUtil.getDate_8(new Date()));
					}

					answer.setBusiness(business);
					answer.setQueueId(queueId);
					int savRet	= followEvaluationService.savePtEvaluationResult(answer,null);
					logger.info("++++getScore() savRet:"+savRet+", id:"+answer.getId()+", userId:"+answer.getUserId());
					logger.info("++++getScore() begin to call followEvaluationService.deleteDraftForPeabody() param userId:"+userId);
					int delRet	= followEvaluationService.deleteDraftForPeabody(userId);
					logger.info("++++getScore() ret from deleteDraftForPeabody() delRet:"+delRet);
		    	}
	    	}
		}
//		paramsMap.put("success", true);
		return new ResultModel<Map<String,Object>>(paramsMap);
    }

	@RequestMapping("/evaluation/getGuide")
	@ResponseBody
	public ResultModel<Map<String, Object>> getGuide(@RequestBody String arg,HttpServletRequest request) throws Exception {
		logger.info("in getGuide----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
        String examinationPaperName = requestParam.getString("examinationPaperName");
        if(StringUtils.isEmpty(examinationPaperName)){
        	logger.info("out getGuide----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，examinationPaperName不能为空");
        }

        /*Map<String, Object> paramMap = new HashMap<String, Object>();*/
        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	logger.info("out getGuide----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者id不能为空");
        }

        Map<String,Object> ptMap = new HashMap<String,Object>();
		ptMap.put("userId",userId);
		ptMap.put("tenantId",tenantId);
		Patient pt = patientService.getPatient(ptMap);
		if(pt == null ){
            throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_PATIENT_NOT_EXIST, "患者信息不存在");
		}

		Map<String,Object> paramsMap = new HashMap<String,Object>();
//		String postion="";
		if(pt.getBirthday()!=null) {
			Date birthday = DateUtil.getDate_8(pt.getBirthday());
			if(Constants.FOLLOW_EVALUATION_NEUR.equals(examinationPaperName)) {

			} else if(Constants.FOLLOW_EVALUATION_BAILEY.equals(examinationPaperName)){
				paramsMap = followEvaluationService.getBaileyScreeningGuide(birthday);
			} else if(Constants.FOLLOW_EVALUATION_GESELL.equals(examinationPaperName)) {
				Map<String,Object> param = new HashMap<String,Object>();
				if(StringUtils.isBlank((String)requestParam.get("evaluationId"))){
		            throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_PATIENT_NOT_EXIST, "记录id");
				}else {
					param.put("evaluationId",requestParam.get("evaluationId"));
				}
				param.put("createTime",requestParam.get("createTime"));
				paramsMap = followEvaluationService.getGesellGuide(param,pt);
			} else if(Constants.FOLLOW_EVALUATION_TEMP.equals(examinationPaperName)) {
				Map<String,Object> param = new HashMap<String,Object>();
				param.put("type",requestParam.get("type"));
				paramsMap = followEvaluationService.getTEMPGuide(param,pt);

			} else if(Constants.FOLLOW_EVALUATION_SMALlWECHSLER.equals(examinationPaperName)) {
			} else if(Constants.FOLLOW_EVALUATION_BIGWECHSLER.equals(examinationPaperName)) {
			} else if(Constants.FOLLOW_EVALUATION_PREGNANT_AIMS.equals(examinationPaperName)||Constants.FOLLOW_EVALUATION_PREGNANT_PEABODY.equals(examinationPaperName)||
					Constants.FOLLOW_EVALUATION_PREGNANT_BSID2.equals(examinationPaperName) || Constants.FOLLOW_EVALUATION_NBNA.equals(examinationPaperName)||
					Constants.FOLLOW_EVALUATION_GROWTH.equals(examinationPaperName)||Constants.FOLLOW_EVALUATION_PREGNANT_GMS.equals(examinationPaperName)) {
				//aims评估结果意见 从表查询
				Map<String,Object> param = new HashMap<String,Object>();
				if(Constants.FOLLOW_EVALUATION_GROWTH.equals(requestParam.get("examinationPaperName"))) {
					param.put("type",requestParam.get("examinationPaperName"));
				}
				param.put("evaluationId",requestParam.get("evaluationId"));
				paramsMap = followEvaluationService.getEvaluationGuide(param);
			}else if(Constants.FOLLOW_EVALUATION_PREGNANT_BSID.equals(examinationPaperName)) {
				Map<String,Object> param = new HashMap<String,Object>();
				if(StringUtils.isBlank((String)requestParam.get("age"))){
		            throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_PATIENT_NOT_EXIST, "年龄必传！");
				}
				param.put("age",requestParam.get("age"));
				paramsMap = followEvaluationService.getEvaluationGuideByAge(param);
			}/*else if(Constants.FOLLOW_EVALUATION_PREGNANT_GMS.equals(examinationPaperName)) {
				Map<String,Object> param = new HashMap<String,Object>();
				param.put("userId",userId);
				param.put("examinationPaperName",examinationPaperName);
				List<Map<String, Object>> list = followEvaluationService.getEvaluationGuideGms(param);
				paramsMap.put("getGuide", list);
			}*/
		}
//		paramsMap.put("success", true);
		return new ResultModel<Map<String,Object>>(paramsMap);
	}

	@RequestMapping("/evaluation/guidemodify")
	@ResponseBody
	public ResultModel<Map<String, Object>> modifyGuide(@RequestBody String arg,HttpServletRequest request) throws Exception {
		logger.info("in modifyGuide----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
        String evaluationId = requestParam.getString("evaluationId");
        if(StringUtils.isEmpty(evaluationId)){
        	logger.info("out modifyGuide----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，评估记录ID不能为空");
        }

        String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	logger.info("out modifyGuide----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，用户ID不能为空");
        }

        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
		String authorId = (String) sessionMap.get("authorId");//用户ID
		String tenantId = (String) sessionMap.get("tenantId");// 租户id

        Map<String,Object> ptMap = new HashMap<String,Object>();
		ptMap.put("userId",userId);
		ptMap.put("tenantId",tenantId);
		Patient pt = patientService.getPatient(ptMap);
		if(pt == null ){
            throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_PATIENT_NOT_EXIST, "患者信息不存在");
		}

//        Map<String,Object> ptMap = new HashMap<String,Object>();
		ptMap.clear();
		ptMap.put("authorId", authorId);
		ptMap.putAll(requestParam);

		Map<String,Object> paramsMap = followEvaluationService.modifyGuide(ptMap);

		// type=7 门诊指导意见新增或修改推送到小程序

		int type = EVALUATION_GUIDE;
		String deptId = (String) sessionMap.get("deptId");// 租户id
		String platType = departmentBasicService.getDepartmentBasicDetails(deptId).getPlatType();

		JSONObject map =new JSONObject();
		map.put("type",type);
		map.put("growId",evaluationId);
		map.put("platType",Integer.parseInt(platType));
		map.put("deptId",deptId);
		HttpUtil.postData(PropertiesUtils.getProperty("redirectUrl") ,map.toJSONString());

		return new ResultModel<Map<String,Object>>(paramsMap);
	}

	@RequestMapping("/evaluation/getHistoryScore")
	@ResponseBody
	public QueryModel<Map<String, Object>> getHistoryScore(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in getHistoryScore----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
        String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	logger.info("out getHistoryScore----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者ID不能为空");
        }

        String type = requestParam.getString("examinationPaperName");
        if(StringUtils.isEmpty(type)){
        	logger.info("out getHistoryScore----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，随访评测类型不能为空");
        }

        List<String> typeList = new ArrayList<String>();
        typeList.add(type);

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.putAll(requestParam);
        paramMap.put("userId",userId);
        paramMap.put("typeList",typeList);

        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        paramMap.put("tenantId", tenantId);

        List<Map<String, Object>> list= followEvaluationService.selectPtEvaluationResults(paramMap);
        int total= 0;
        if(!CollectionUtils.isEmpty(list)){
        	total= followEvaluationService.selectPtEvaluationResultCount(paramMap);
        }
		logger.info("out getHistoryScore----arg==" + list);
		return new QueryModel<Map<String,Object>>(list,total);
    }

	@RequestMapping("/evaluation/scoredetail")
	@ResponseBody
	public ResultModel<Map<String, Object>> getHistoryScoreDetail(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in getHistoryScoreDetail----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
        String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	logger.info("out getHistoryScoreDetail----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者ID不能为空");
        }

        String evaluationId = requestParam.getString("evaluationId");
        if(StringUtils.isEmpty(evaluationId)){
        	logger.info("out getHistoryScoreDetail----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，评测记录id不能为空");
        }

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.putAll(requestParam);

        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        paramMap.put("tenantId", tenantId);

        Map<String, Object> list= followEvaluationService.selectPtEvaluationResultDetail(paramMap);
		logger.info("out getHistoryScore----arg==" + list);
		return new ResultModel<Map<String,Object>>(list);
    }


	@RequestMapping("/evaluation/patientListqry")
	@ResponseBody
	public Map<String, Object> patientListqry(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in patientListqry----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}

        String type = requestParam.getString("examinationPaperName");
        if(StringUtils.isEmpty(type)){
        	logger.info("out getHistoryScore----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，随访评测类型不能为空");
        }

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.putAll(requestParam);
//        paramMap.put("examinationPaperName",type);

        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        String authorId = (String) sessionMap.get("authorId");// 用户ID
        paramMap.put("tenantId", tenantId);
        paramMap.put("authorId", authorId);

        int page = requestParam.getIntValue("page");
        int rows = requestParam.getIntValue("rows");
        page = page == 0 ? 1 : page;
        rows = rows == 0 ? 20 : rows;

        paramMap.put("page", (page - 1) * rows);
        paramMap.put("rows", rows);

        String jsonStr = requestParam.getString(Constants.INF_INPUTPARAM_DATATABLE_FIELD);

        int draw = 0;
        if (!StringUtils.isEmpty(jsonStr)) {
            JSONObject jsonTable = (JSONObject) JSONObject.parse(jsonStr);
            draw = jsonTable.getIntValue("draw");
            paramMap.put("page", jsonTable.getIntValue("start"));
            paramMap.put("rows", jsonTable.getIntValue("length"));
        }

        List<Map<String, Object>> list= followEvaluationService.getEvaluationPatientList(paramMap);
        int total= 0;
        if(!CollectionUtils.isEmpty(list)){
        	total= followEvaluationService.getEvaluationPatientCount(paramMap);
        }

        Map<String, Object> retMap = new HashMap<String, Object>();
        retMap.put("rows", list);
        retMap.put("total", total);
        // 针对Datatable特殊处理
        if (!StringUtils.isEmpty(jsonStr)) {
            retMap.put("draw", draw);
            retMap.put("recordsTotal", total);
            retMap.put("recordsFiltered", total);
        }
		logger.info("out patientListqry----arg==" + list);
		return retMap;
    }


	@RequestMapping("/evaluation/albertacurvedata")
	@ResponseBody
	public ResultModel<Map<String, Object>> getAimsCurvedata(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in getAimsCurvedata----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
        String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	logger.info("out getAimsCurvedata----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者ID不能为空");
        }

        String type = requestParam.getString("examinationPaperName");
        if(StringUtils.isEmpty(type)){
        	logger.info("out getAimsCurvedata----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，随访评测类型不能为空");
        }

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.putAll(requestParam);
//        paramMap.put("userId",userId);
        paramMap.put("type",type);

        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        paramMap.put("tenantId", tenantId);

        Map<String, Object> rspMap= followEvaluationService.getAimsCurvedata(paramMap);
		logger.info("out getAimsCurvedata----arg==" +rspMap);
		return new ResultModel<Map<String,Object>>(rspMap);
    }


	@RequestMapping("/evaluation/getPeabodydata")
	@ResponseBody
	public ResultModel<Map<String, Object>> getPeabodydata(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in getAimsCurvedata----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
        String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	logger.info("out getAimsCurvedata----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者ID不能为空");
        }

        String type = requestParam.getString("examinationPaperName");
        if(StringUtils.isEmpty(type)){
        	logger.info("out getAimsCurvedata----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，随访评测类型不能为空");
        }

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.putAll(requestParam);
//        paramMap.put("userId",userId);
        paramMap.put("type",type);

        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        paramMap.put("tenantId", tenantId);

        Map<String, Object> rspMap= followEvaluationService.getPeabodydata(paramMap);
		logger.info("out getAimsCurvedata----arg==" +rspMap);
		return new ResultModel<Map<String,Object>>(rspMap);
    }


	//GMS保存的信息
	@RequestMapping("/evaluation/getGmsScore")
	@ResponseBody
	public ResultModel<Map<String, Object>> getGmsScore(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in getGmsScore----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
        String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	logger.info("out getGmsScore----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者ID不能为空");
        }

        String examinationPaperName = requestParam.getString("examinationPaperName");
        if(StringUtils.isEmpty(examinationPaperName)){
        	logger.info("out getGmsScore----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，examinationPaperName不能为空");
        }
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.putAll(requestParam);

        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        paramMap.put("tenantId", tenantId);

        Map<String, Object> list= followEvaluationService.selectGmsResultDetail(paramMap);
		logger.info("out getGmsScore----arg==" + list);
		return new ResultModel<Map<String,Object>>(list);
    }


	@RequestMapping("/evaluation/patientListqryOwn")
	@ResponseBody
	public ResultModel<Map<String, Object>> patientListqryOwn(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in patientListqryOwn----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}

        String type = requestParam.getString("examinationPaperName");
        if(StringUtils.isEmpty(type)){
        	logger.info("out getHistoryScore----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，随访评测类型不能为空");
        }

        Map<String, Object> paramMap = new HashMap<String, Object>();
        if(type.indexOf(";")!=-1) {
	        //获取评估类型，并分割类型
	        List<String> typeList = new ArrayList<String>();
	        String [] str = type.split(";");
	        for(int i = 0;i<str.length;i++) {
	        	 typeList.add(str[i]);
	        }
	        paramMap.put("typeList",typeList);
        }
        paramMap.putAll(requestParam);
//        paramMap.put("examinationPaperName",type);

        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        String authorId = (String) sessionMap.get("authorId");// 用户ID
        paramMap.put("tenantId", tenantId);
        paramMap.put("authorId", authorId);

        int page = requestParam.getIntValue("page");
        int rows = requestParam.getIntValue("rows");
        page = page == 0 ? 1 : page;
        rows = rows == 0 ? 20 : rows;

        paramMap.put("page", (page - 1) * rows);
        paramMap.put("rows", rows);

        String jsonStr = requestParam.getString(Constants.INF_INPUTPARAM_DATATABLE_FIELD);

        int draw = 0;
        if (!StringUtils.isEmpty(jsonStr)) {
            JSONObject jsonTable = (JSONObject) JSONObject.parse(jsonStr);
            draw = jsonTable.getIntValue("draw");
            paramMap.put("page", jsonTable.getIntValue("start"));
            paramMap.put("rows", jsonTable.getIntValue("length"));
        }
        paramMap.put("beginTime", requestParam.getString("beginTime"));
        paramMap.put("endTime", requestParam.getString("endTime"));

        List<Map<String, Object>> list= followEvaluationService.getEvaluationPatientList(paramMap);
        int total= 0;
        if(!CollectionUtils.isEmpty(list)){
        	total= followEvaluationService.getEvaluationPatientCount(paramMap);
        }

        Map<String, Object> retMap = new HashMap<String, Object>();
        retMap.put("rows", list);
        retMap.put("total", total);
        // 针对Datatable特殊处理
        if (!StringUtils.isEmpty(jsonStr)) {
            retMap.put("draw", draw);
            retMap.put("recordsTotal", total);
            retMap.put("recordsFiltered", total);
        }
		logger.info("out patientListqry----arg==" + list);
		return new ResultModel<Map<String,Object>>(retMap);
    }

	//查询用户评估信息查询当前用户评估的记录，以每天分组
	@RequestMapping("/evaluation/queryPtResultTimes")
	@ResponseBody
	public ResultModel<List<Map<String, Object>>> queryPtResultTimes(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in queryPtResultTimes----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
        String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者ID不能为空");
        }

        String evaluationType = requestParam.getString("evaluationType");
        if(StringUtils.isEmpty(evaluationType)){
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，评测类型不能为空");
        }

        //获取评估类型，并分割类型
        List<String> typeList = new ArrayList<String>();
        String [] str = evaluationType.split(";");
        for(int i = 0;i<str.length;i++) {
        	 typeList.add(str[i]);
        }

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.putAll(requestParam);
        paramMap.put("typeList",typeList);

        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        paramMap.put("tenantId", tenantId);

        List<Map<String, Object>> list= followEvaluationService.queryPtResultTimes(paramMap);
		logger.info("out getHistoryScore----arg==" + list);
		return new ResultModel<List<Map<String,Object>>>(list);
    }

	//查询用户当天的评估信息
	@RequestMapping("/evaluation/queryPtResultDay")
	@ResponseBody
	public ResultModel<List<Map<String, Object>>> queryPtResultDay(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in queryPtResultDay----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
        String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者ID不能为空");
        }

        String evaluationType = requestParam.getString("evaluationType");
        if(StringUtils.isEmpty(evaluationType)){
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，评测类型不能为空");
        }

        String createTime = requestParam.getString("createTime");
        if(StringUtils.isEmpty(createTime)){
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，评估时间不能为空");
        }

        //获取评估类型，并分割类型
        List<String> typeList = new ArrayList<String>();
        String [] str = evaluationType.split(";");
        for(int i = 0;i<str.length;i++) {
        	 typeList.add(str[i]);
        }

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.putAll(requestParam);
        paramMap.put("typeList",typeList);

        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        paramMap.put("tenantId", tenantId);

        List<Map<String, Object>> list= followEvaluationService.queryPtResultDay(paramMap);
		logger.info("out queryPtResultDay----arg==" + list);
		return new ResultModel<List<Map<String,Object>>>(list);
    }


	@RequestMapping("/mabc/getUserRecordList")
	@ResponseBody
	public Map<String, Object> getUserRecordList(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in getUserRecordList----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.putAll(requestParam);
//        paramMap.put("examinationPaperName",type);

        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        String authorId = (String) sessionMap.get("authorId");// 用户ID
        paramMap.put("tenantId", tenantId);
        paramMap.put("authorId", authorId);

        int page = requestParam.getIntValue("page");
        int rows = requestParam.getIntValue("rows");
        page = page == 0 ? 1 : page;
        rows = rows == 0 ? 20 : rows;

        paramMap.put("page", (page - 1) * rows);
        paramMap.put("rows", rows);

        String jsonStr = requestParam.getString(Constants.INF_INPUTPARAM_DATATABLE_FIELD);

        int draw = 0;
        if (!StringUtils.isEmpty(jsonStr)) {
            JSONObject jsonTable = (JSONObject) JSONObject.parse(jsonStr);
            draw = jsonTable.getIntValue("draw");
            paramMap.put("page", jsonTable.getIntValue("start"));
            paramMap.put("rows", jsonTable.getIntValue("length"));
        }

        //只查基本信息
//        paramMap.put("examinationPaperName",Constants.MABC_BASIC_INFO);
		List<String> examinationPaperNameList = new ArrayList<>();
		examinationPaperNameList.add(Constants.MABC_BASIC_INFO);
		examinationPaperNameList.add(Constants.MABC_BASIC_FIVE_INFO);
		paramMap.put("examinationPaperNameList",examinationPaperNameList);
        List<Map<String, Object>> list= followEvaluationService.getEvaluationPatientList(paramMap);
        int total= 0;
        if(!CollectionUtils.isEmpty(list)){
        	Map<String,Object> queryMap = new HashMap<String,Object>();
    		queryMap.put("type",Constants.ASSESSMENT_MABC_ALL_TYPE);
    		queryMap.put("paramCode",Constants.MABC_ALL);
    		Object mabcDesc = "";
    		List<Map<String,Object>> busiList = bsStaticParamService.getStaticParamsByCondition(queryMap);
    		if(!CollectionUtils.isEmpty(busiList)){
    			mabcDesc = busiList.get(0).get("paramName");
    		}

        	for(int i = 0;i<list.size();i++){
        		list.get(i).put("questionName",mabcDesc);
        	}

        	total= followEvaluationService.getEvaluationPatientCount(paramMap);
        }

        Map<String, Object> retMap = new HashMap<String, Object>();
        retMap.put("rows", list);
        retMap.put("total", total);
        // 针对Datatable特殊处理
        if (!StringUtils.isEmpty(jsonStr)) {
            retMap.put("draw", draw);
            retMap.put("recordsTotal", total);
            retMap.put("recordsFiltered", total);
        }
		logger.info("out getUserRecordList----arg==" + list);
		return retMap;
    }


	@RequestMapping("/mabc/getBasicInfo")
	@ResponseBody
	public ResultModel<Object> getMabcBasicInfo(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in getMabcBasicInfo----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.putAll(requestParam);
//        paramMap.put("examinationPaperName",type);

        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        String authorId = (String) sessionMap.get("authorId");// 用户ID
        paramMap.put("tenantId", tenantId);
        paramMap.put("authorId", authorId);

        Map<String, Object> retMap = mabcEvaluationService.getMabcBasicInfo(paramMap);
		logger.info("out getMabcBasicInfo----arg==");
		return new ResultModel<Object>(retMap);
    }

	//
  	@RequestMapping("/mabc/getMabcQuestionList")
	@ResponseBody
	public ResultModel<Object> getMabcQuestionList(@RequestBody String arg,HttpServletRequest request) throws Exception {
		logger.info("in getMabcQuestionList----arg==" + arg);
	    JSONObject jsonEsb = JSON.parseObject(arg);
	    JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}

	    String userId = requestParam.getString("userId");
	    if (StringUtils.isEmpty(userId)) {
	        throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "用户id不能为空！"));
	    }


        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id

	    Map<String,Object> parma = new HashMap<String,Object>();
		parma.put("tenantId",tenantId);
		parma.putAll(requestParam);

		String ageState = requestParam.getString("ageState");// 年龄状态

		if (("0").equals(ageState)) {
			parma.put("excludeBusiId",Constants.MABC_BASIC_INFO);//不查基本信息
		} else if (("1").equals(ageState)){
			parma.put("excludeBusiId",Constants.MABC_BASIC_FIVE_INFO);//不查基本信息
		} else if (("2").equals(ageState)){
			parma.put("excludeBusiId",Constants.MABC_BASIC_SIX_INFO);//不查基本信息
		}

	    Map<String,Object> retout = mabcEvaluationService.getMabcCompleteList(parma);
	    return new ResultModel<Object>(retout);
	}

  	@RequestMapping("/mabc/getMabcAnswerDetails")
	@ResponseBody
	public ResultModel<Map<String, Object>> getMabcAnswerDetails(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in getMabcAnswerDetails----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}

		String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	logger.info("out getMabcAnswerDetails----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者ID不能为空");
        }

        String evaluationId = requestParam.getString("answerId");
        if(StringUtils.isEmpty(evaluationId)){
        	logger.info("out getMabcAnswerDetails----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，评测记录id不能为空");
        }

		requestParam.put("evaluationId",evaluationId);
        Map<String, Object> resultMap= mabcEvaluationService.getMabcAnswerDetail(requestParam);

		logger.info("out getMabcAnswerDetails----arg==" + resultMap);
		return new ResultModel<Map<String,Object>>(resultMap);
    }

  	@RequestMapping("/mabc/getGuide")
	@ResponseBody
	public ResultModel<Map<String, Object>> getMabcGuide(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in getMabcGuide----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}

		String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	logger.info("out getMabcGuide----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者ID不能为空");
        }

        String evaluationId = requestParam.getString("answerId");
        if(StringUtils.isEmpty(evaluationId)){
        	logger.info("out getMabcGuide----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，评测记录id不能为空");
        }

        /*Map<String, Object> paramMap = new HashMap<String, Object>();*/
        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        Map<String,Object> ptMap = new HashMap<String,Object>();
		ptMap.put("userId",userId);
		ptMap.put("tenantId",tenantId);
		Patient pt = patientService.getPatient(ptMap);
		if(pt == null ){
            throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_PATIENT_NOT_EXIST, "患者信息不存在");
		}

		Map<String,Object> param = new HashMap<String,Object>();
		param.put("evaluationId",evaluationId);
        Map<String, Object> resultMap= followEvaluationService.getEvaluationGuide(param);

		logger.info("out getMabcGuide----arg==" + resultMap);
		return new ResultModel<Map<String,Object>>(resultMap);
    }

  	//查询最新的一条数据
  	@RequestMapping("/evaluation/getGesellScore")
  	@ResponseBody
  	public ResultModel<Map<String, Object>> getGesellScore(@RequestBody String arg,
              HttpServletRequest request) throws Exception{
  		logger.info("in getGesellScore----arg==" + arg);
          JSONObject jsonEsb = JSON.parseObject(arg);
          JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
  		if(null == requestParam ){
  			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
  		}
          String userId = requestParam.getString("userId");
          if(StringUtils.isEmpty(userId)){
          	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者ID不能为空");
          }

          String examinationPaperName = requestParam.getString("examinationPaperName");
          if(StringUtils.isEmpty(examinationPaperName)){
          	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，examinationPaperName不能为空");
          }
          Map<String, Object> paramMap = new HashMap<String, Object>();
          paramMap.putAll(requestParam);

          Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
          String tenantId = (String) sessionMap.get("tenantId");// 租户id
          paramMap.put("tenantId", tenantId);

          Map<String, Object> list= followEvaluationService.selectGesellScore(paramMap);
  		return new ResultModel<Map<String,Object>>(list);
      }


  	@RequestMapping("/evaluation/getDSTHistoryScore")
	@ResponseBody
	public ResultModel<Map<String, Object>> getDSTHistoryScore(@RequestBody String arg,
            HttpServletRequest request) throws Exception{
		logger.info("in getDSTHistoryScore----arg==" + arg);
        JSONObject jsonEsb = JSON.parseObject(arg);
        JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
        String userId = requestParam.getString("userId");
        if(StringUtils.isEmpty(userId)){
        	logger.info("out getHistoryScore----arg== null");
        	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者ID不能为空");
        }
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.putAll(requestParam);
        paramMap.put("userId",userId);
        Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        paramMap.put("tenantId", tenantId);

        Map<String,Object> mapOut= followEvaluationService.selectPtDSTResults(paramMap);
		return new ResultModel<Map<String,Object>>(mapOut);
    }

  	//查询gesell评估历史记录
  	@RequestMapping("/evaluation/getGesellScoreList")
  	@ResponseBody
  	public ResultModel<List<Map<String, Object>>> getGesellScoreList(@RequestBody String arg,
              HttpServletRequest request) throws Exception{
  		logger.info("in getGesellScore----arg==" + arg);
          JSONObject jsonEsb = JSON.parseObject(arg);
          JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
  		if(null == requestParam ){
  			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
  		}
          String userId = requestParam.getString("userId");
          if(StringUtils.isEmpty(userId)){
          	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者ID不能为空");
          }

          String examinationPaperName = requestParam.getString("examinationPaperName");
          if(StringUtils.isEmpty(examinationPaperName)){
          	throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，examinationPaperName不能为空");
          }
          Map<String, Object> paramMap = new HashMap<String, Object>();
          paramMap.putAll(requestParam);

          Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
          String tenantId = (String) sessionMap.get("tenantId");// 租户id
          paramMap.put("tenantId", tenantId);

          List<Map<String, Object>> list= followEvaluationService.selectGesellScoreList(paramMap);
  		return new ResultModel<List<Map<String,Object>>>(list);
      }

	/**
	 * 删除某个患者的1条评估历史记录。（物理）
	 * @param evaluationId
	 * @return 是否删除成功了。
	 * @throws Exception
	 */
	@RequestMapping("/evaluation/history/delete")
	@ResponseBody
	public Boolean deleteEvaluationHistory(@RequestParam(value = "evaluation_id", required = true) final String evaluationId) throws Exception {
		return followEvaluationService.deleteEvaluationHistory(evaluationId);
	}

	/**
	 * 保存peabody量表评测的草稿。
	 * @param arg
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/evaluation/peabody/saveDraft")
	@ResponseBody
	public ResultModel<Map<String, Object>> saveDraftForPeabody(@RequestBody String arg,
													 HttpServletRequest request) throws Exception {
		logger.info("saveDraftForPeabody()----arg==" + arg);
		JSONObject jsonEsb = JSON.parseObject(arg);
		JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
		String examinationPaperName = requestParam.getString("examinationPaperName");
		if(StringUtils.isEmpty(examinationPaperName)){
			logger.error("saveDraftForPeabody()----arg== null");
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，examinationPaperName不能为空");
		}
		Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
		String tenantId = (String) sessionMap.get("tenantId");// 租户id
		String authorId = (String) sessionMap.get("authorId");// 医生ID
		String userId = requestParam.getString("userId");
		if(StringUtils.isEmpty(userId)){
			logger.error("saveDraftForPeabody()----arg== null");
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者id不能为空");
		}

		String postionIds = requestParam.getString("postionIds");
		String taskId = requestParam.getString("taskId");
		if(StringUtils.isEmpty(postionIds)){
			logger.info("out getAllPostion----arg== null");
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，postionIds不能为空");
		}
		String business = requestParam.getString("business");
		if(StringUtils.isBlank(business)) {
			business = "评估医生";
		}
		String sourceType = requestParam.getString("sourceType");
		Map<String,Object> ptMap = new HashMap<String,Object>();
		ptMap.put("userId",userId);
		ptMap.put("tenantId",tenantId);
		Patient pt = patientService.getPatient(ptMap);
		if(pt == null ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_PATIENT_NOT_EXIST, "患者信息不存在");
		}
		Map<String,Object> paramsMap = new HashMap<String,Object>();
		//保存peabody评测草稿入库。
		final String draftId	= SeqUtil.getSeqNo();
		PtEvaluationResult draft= new PtEvaluationResult();
		draft.setType(examinationPaperName);
		draft.setId(draftId);
		draft.setDoctorid(authorId);
		draft.setCreateTime(DateUtil.getSysDateA());
		draft.setScore(JSON.toJSONString(paramsMap));
		logger.info("++++saveDraftForPeabody() draftId:"+draftId+", param postionIds:"+postionIds);
		draft.setResult(postionIds);
		if(!StringUtils.isEmpty(requestParam.getString("sourceType"))){
			draft.setSourcetype(requestParam.getString("sourceType")); //暂时只有随访系统评估
		}else{
			draft.setSourcetype(Constants.SOURCE_TYPE_FOLLOW); //暂时只有随访系统评估
		}
		draft.setSourceid(authorId);
		draft.setTenantId(tenantId);
		draft.setUserId(userId);
		draft.setTaskId(taskId);
		if(!StringUtils.isBlank(requestParam.getString("testTime"))) {
			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
			try {
				format.parse(requestParam.getString("testTime"));
				draft.setTestTime(requestParam.getString("testTime"));
			} catch (Exception e) {
				throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_PATIENT_NOT_EXIST, "日期格式不正确");
			}
		}else {
			draft.setTestTime(DateUtil.getDate_8(new Date()));
		}
		draft.setBusiness(business);

		int saveRet	= followEvaluationService.saveDraftForPeabody(draft);
		Map<String, Object> retMap	= new HashMap<>();
		if (1 == saveRet)	{
			retMap.put("success", true);
			retMap.put("msg", "保存peabody量表评测草稿成功了！");
		} else {
			retMap.put("success", false);
			retMap.put("msg", "保存peabody量表评测草稿失败了！");
		}

		return new ResultModel(retMap);
	}

	/**
	 * 查询peabody量表评测草稿。
	 * @param arg
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/evaluation/peabody/queryDraft")
	@ResponseBody
	public ResultModel<Map<String,Object>> queryDraftForPeabody(@RequestBody String arg) throws Exception {
		logger.info("queryDraftForPeabody()----arg==" + arg);
		JSONObject json	= JSON.parseObject(arg);
		JSONObject requestParam = json.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if (null == requestParam) {
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
		final String patUserId	= requestParam.getString("userId");
		if (StringUtils.isEmpty(patUserId)) {
			logger.error("queryDraftForPeabody()----arg== null");
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参校验失败，userId不能为空");
		}
		Map<String,Object> paraMap	= new HashMap<>();
		paraMap.put("userId", patUserId);
		final List<PtEvaluationResult> draftList	= followEvaluationService.selectDraftForPeabody(paraMap);
		Map<String,Object> retMap	= new HashMap<>();
		if (null != draftList && draftList.size()>0)	{
			retMap.put("success", true);
			retMap.put("result", draftList.get(0));
		} else {
			retMap.put("success", false);
			retMap.put("msg", "患者宝宝"+patUserId+"没有peabody量表草稿！");
		}
		return new ResultModel(retMap);
	}

	@RequestMapping("/evaluation/getAimsHistoryScore")
	@ResponseBody
	public ResultModel<Object> getAimsHistoryScore(@RequestBody String arg,
														   HttpServletRequest request) throws Exception{
		logger.info("in getAimsHistoryScore----arg==" + arg);
		JSONObject jsonEsb = JSON.parseObject(arg);
		JSONObject requestParam = jsonEsb.getJSONObject(Constants.INF_INPUTPARAM_COMMONFIELD); //统一节点处理
		if(null == requestParam ){
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无data节点！");
		}
		String userId = requestParam.getString("userId");
		if(StringUtils.isEmpty(userId)){
			logger.info("out getHistoryScore----arg== null");
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，患者ID不能为空");
		}

		String type = requestParam.getString("examinationPaperName");
		if(StringUtils.isEmpty(type)){
			logger.info("out getHistoryScore----arg== null");
			throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,"入参校验失败，随访评测类型不能为空");
		}

		List<String> typeList = new ArrayList<String>();
		typeList.add(type);

		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.putAll(requestParam);
		paramMap.put("userId",userId);
		paramMap.put("typeList",typeList);

		Map<String, Object> sessionMap = ToolUtils.getSessionInfo(request);
		String tenantId = (String) sessionMap.get("tenantId");// 租户id
		paramMap.put("tenantId", tenantId);

		List<Map<String, Object>> retList = new ArrayList<Map<String, Object>>();
		HashMap<String, Object> retMap;


		List<Map<String, Object>> list = followEvaluationService.selectPtEvaluationResults(paramMap);
		for (Map<String, Object> map : list) {
			retMap = new HashMap<String, Object>();
			String result = (String) map.get("result");
			retMap.put("testTime", map.get("testTime"));
			retMap.put("questionId", "sf_aims");

			JSONObject retsultJson = JSONObject.parseObject(result);
			JSONObject totalJson = (JSONObject) retsultJson.get("total");
			Object totalScore = totalJson.get("totalScore");
			retMap.put("totalScore", totalScore);
			retList.add(retMap);
		}
		return new ResultModel(retList);
	}

}
